package com.carey.blog.sync;

import com.carey.blog.model.BlogSync;
import com.carey.blog.sync.blogjava.BlogJavaBlog;
import com.carey.blog.sync.cnblogs.CnBlogsBlog;
import com.carey.blog.sync.csdnblog.CSDNBlog;

/**
 * Blog factory.
 * 
 */
public final class BlogFactory {

	/**
	 * Gets a {@link MetaWeblog} by the specified external blogging system name.
	 * 
	 * @param externalSysName
	 *            the specified external blogging system name
	 * @return MetaWeblog
	 */
	public static MetaWeblog getMetaWeblog(final String externalSysName) {
		if (BlogSync.BLOG_SYNC_CSDN_BLOG.equals(externalSysName)) {
			return new CSDNBlog();
		} else if (BlogSync.BLOG_SYNC_CNBLOGS.equals(externalSysName)) {
			return new CnBlogsBlog();
		} else if (BlogSync.BLOG_SYNC_BLOGJAVA.equals(externalSysName)) {
			return new BlogJavaBlog();
		} else {
			throw new RuntimeException(
					"Not supported external blogging system[" + externalSysName
							+ "]");
		}
	}

	/**
	 * Private default constructor.
	 */
	private BlogFactory() {
	}
}
